import React, {useContext} from 'react';
import globalContext from "../context";
function Child(props) {
    const {userName,dispatch} = useContext(globalContext);
    return (
        <div>
            <button onClick={()=>{
                dispatch({type:"CHANGE_USERNAME",payload:"wangwenliang"});
            }}>点我</button>
            <p>child->{userName}</p>
        </div>
    );
}

export default Child;